package com.spzx.cart.api.factory;

import com.spzx.cart.api.RemoteCartService;
import com.spzx.cart.api.domain.CartInfo;
import com.spzx.common.core.domain.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;

@Slf4j
public class RemoteCartFallbackFactory implements FallbackFactory<RemoteCartService> {
    @Override
    public RemoteCartService create(Throwable cause) {
        log.error("获取详情sku失败",cause.getMessage());
        return new RemoteCartService() {
            @Override
            public R<List<CartInfo>> getcartcheckedlist(String source) {
                return R.fail("获取商品SKU详情失败" + cause.getMessage());
            }

            @Override
            public R<Boolean> updateCartPrice(String source) {
                return R.fail("获取商品SKU详情失败" + cause.getMessage());
            }

            @Override
            public R<Boolean> deleteCartCheckedList(String source) {
                return R.fail("删除商品失败"+cause.getMessage());
            }
        };
    }
}
